﻿function ShowTabs(tabidnum,tabnum,tabnums,tabname,tabidname) {
	for (var i=0;i<tabnums;i++) {
		document.getElementById("Tabs"+tabidnum+i).style.display="none";
		document.getElementById(tabname+tabidnum+i).className="title5";
		document.getElementById(tabidname+tabidnum+i).className="title3";
	}
	document.getElementById(tabname+tabidnum+tabnum).className="title6";
	document.getElementById(tabidname+tabidnum+tabnum).className="title4";
	document.getElementById("Tabs"+tabidnum+tabnum).style.display="";
}

function doChange(objText, objDrop, objPic, DownloadDir, UploadDir, InstallDir, Upath, Dir) {
	if (!objDrop) return false;
	var str = document.getElementById(objText).value;
	var obj = document.getElementById(objDrop);
	var arr = str.split("|");
	obj.length=0;
	for (var i=0; i<arr.length; i++) {
		if (arr[i].substring(arr[i],DownloadDir.length)==DownloadDir) {
			arr[i] = arr[i].replace(Upath,'{$download_dir}' + Dir);
		}else if (arr[i].substring(arr[i],UploadDir.length)==UploadDir) {
			arr[i] = arr[i].replace(Upath,'{$upload_dir}' + Dir);
		}else if (arr[i].substring(arr[i],InstallDir.length)==InstallDir) {
			arr[i] = arr[i].replace(Upath,'{$InstallDir}' + Dir);
		}else{
			arr[i] = arr[i]
		}
		document.getElementById(objPic).value = arr[0];
		obj.options[i] = new Option(arr[i], arr[i]);
		//document.getElementById(objText).value = ""
	}
}

//表单提交客户端检测
function doSubmit(objTitle,objClassID,objContent,objLinkUrl,objAttrNotNull) {
	if (isEmpty(document.myform.Title.value)) {
		Dialog.warn(objTitle, function() {
			document.myform.Title.focus();
		});
		return false;
	}
	if (isEmpty(document.myform.ClassID.value)||document.myform.ClassID.value=="0") {
		Dialog.warn(objClassID, function() {
			document.myform.ClassID.focus();
		});
		return false;
	}
	if (!isEmpty(objAttrNotNull)) {
		arr = objAttrNotNull.split(",");
		for (var i=0; i<arr.length; i++) {
			objAttrNotNull = arr[i].split("|");
			if (objAttrNotNull[0]=="1") {
				Attrcontent = UE.getEditor(objAttrNotNull[1]).getContent();
				if (isEmpty(Attrcontent)) {
					Dialog.warn(objAttrNotNull[2], function() {
						UE.getEditor(objAttrNotNull[1]).focus();
					});
					return false;
				}
			}else if (objAttrNotNull[0]=="2") {
				var val=$('input:radio[name="'+objAttrNotNull[1]+'"]:checked').val();
				if (isEmpty(val)){
					Dialog.warn(objAttrNotNull[2]);
					return false;
				}
			}else if (objAttrNotNull[0]=="3") {
				var val=$('input:checkbox[name="'+objAttrNotNull[1]+'"]:checked').val();
				if (isEmpty(val)){
					Dialog.warn(objAttrNotNull[2]);
					return false;
				}
			}else{
				if (isEmpty(document.getElementById(objAttrNotNull[1]).value)) {
					Dialog.warn(objAttrNotNull[2], function() {
						document.getElementById(objAttrNotNull[1]).focus();
					});
					return false;
				}
			}
		}
	}
	//getHTML()为eWebEditor自带的接口函数，功能为取编辑区的内容
	if ("Yes"!=$V("#UseLinkUrl")) {
		content = UE.getEditor('Content').getContent();
		if (isEmpty(content)) {
			Dialog.warn(objContent, function() {
				UE.getEditor('Content').focus();
			});
			return false;
		}
	}else{
		if (isEmpty(document.myform.LinkUrl.value)) {
			Dialog.warn(objLinkUrl, function() {
				document.myform.LinkUrl.focus();
			});
			return false;
		}
	}
}

//编辑器相关
function doPreview(objname,Wpath,Upath) {
	var obj=document.getElementById(objname);
	if (obj.length==0) return false;
	var url=obj.value;
	if (url) {
		url = url.replace("{$InstallDir}",Wpath);
		url = url.replace("{$download_dir}",Upath);
		var sExt=url.substr(url.lastIndexOf(".")+1);
		sExt=sExt.toUpperCase();
		var sHTML;
		switch(sExt){
		case "GIF":
		case "JPG":
		case "JPEG":
		case "BMP":
		case "PNG":
			sHTML = "<img border=0 src='" + url + "' width='140' height='120'>";
			break;
		case "SWF":
			sHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='140' height='120'><param name='movie' value='" + url + "' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='" + url + "' quality='high' wmode='transparent' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='140' height='120'></embed></object>";
			break;
		default:
			sHTML = "";
			break;
		}
		tdPreview.innerHTML = sHTML;
	}else{
		tdPreview.innerHTML = "";
	}
}

function doPreviews(objname,Wpath,Upath) {
	var obj=document.getElementById(objname);
	if (obj.length==0) return false;
	var url=obj.value;
	if (url) {
		url = url.split("|");
		url = url[1]
		url = url.replace("{$InstallDir}",Wpath);
		url = url.replace("{$download_dir}",Upath);
		var sExt=url.substr(url.lastIndexOf(".")+1);
		sExt=sExt.toUpperCase();
		var sHTML;
		switch(sExt){
		case "GIF":
		case "JPG":
		case "JPEG":
		case "BMP":
		case "PNG":
			sHTML = "<img border=0 src='" + url + "' width='140' height='120'>";
			break;
		case "SWF":
			sHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='140' height='120'><param name='movie' value='" + url + "' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='" + url + "' quality='high' wmode='transparent' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='140' height='120'></embed></object>";
			break;
		default:
			sHTML = "";
			break;
		}
		tdPreview.innerHTML = sHTML;
	}else{
		tdPreview.innerHTML = "";
	}
}

function InsertEditor(objname,Wpath,Upath) {
	var obj=document.getElementById(objname);
	if (obj.length==0) return false;
	var url=obj.value;
	url = url.replace("{$InstallDir}",Wpath);
	url = url.replace("{$download_dir}",Upath);
	var sFilePic = getFilePic(url);
  	var sPicStr = ""
		switch(sFilePic){
		case "gif.gif":
		case "jpg.gif":
		case "bmp.gif":
		case "png.gif":
			sPicStr = "<a href='"+url+"' target='_blank'><img src='"+url+"' border='0'></a><br>";
			break;
		case "swf.gif":
			sPicStr = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='180' height='140'><param name='movie' value='"+url+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='"+url+"' quality='high' wmode='transparent' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='180' height='140'></embed></object><br>";
			break;
		default:
			sPicStr = ""
			break;
		}
	//eWebEditor1.eWebEditor.focus();
	//document.getElementById("eWebEditor1").contentWindow.insertHTML(sPicStr+"<br>");
	UE.getEditor('Content').execCommand('insertHtml', sPicStr+"<br>");
}

function SetPicUrl(objname,Insobjname) {
	var obj=document.getElementById(objname);
	if (obj.length==0) return false;
	document.getElementById(Insobjname).value=obj.value;
}

function getFilePic(url) {
	var sExt;
	sExt=url.substr(url.lastIndexOf(".")+1);
	sExt=sExt.toUpperCase();
	var sPicName;
	switch(sExt){
	case "TXT":
		sPicName = "txt.gif";
		break;
	case "DOC":
		sPicName = "doc.gif";
		break;
	case "PDF":
		sPicName = "pdf.gif";
		break;
	case "MDB":
		sPicName = "mdb.gif";
		break;
	case "GIF":
		sPicName = "gif.gif";
		break;
	case "JPG":
	case "JPEG":
		sPicName = "jpg.gif";
		break;
	case "BMP":
		sPicName = "bmp.gif";
		break;
	case "PNG":
		sPicName = "png.gif";
		break;
	case "ASP":
	case "JSP":
	case "JS":
	case "PHP":
	case "PHP3":
	case "ASPX":
		sPicName = "code.gif";
		break;
	case "HTM":
	case "HTML":
	case "SHTML":
		sPicName = "htm.gif";
		break;
	case "ZIP":
		sPicName = "zip.gif";
		break;
	case "RAR":
		sPicName = "rar.gif";
		break;
	case "EXE":
		sPicName = "exe.gif";
		break;
	case "AVI":
		sPicName = "avi.gif";
		break;
	case "MPG":
	case "MPEG":
	case "ASF":
		sPicName = "mp.gif";
		break;
	case "RA":
	case "RM":
		sPicName = "rm.gif";
		break;
	case "MP3":
		sPicName = "mp3.gif";
		break;
	case "MID":
	case "MIDI":
		sPicName = "mid.gif";
		break;
	case "WAV":
		sPicName = "audio.gif";
		break;
	case "XLS":
	case "XLSX":
		sPicName = "xls.gif";
		break;
	case "PPT":
	case "PPS":
	case "PPSX":
		sPicName = "ppt.gif";
		break;
	case "SWF":
		sPicName = "swf.gif";
		break;
	default:
		sPicName = "unknow.gif";
		break;
	}
	return sPicName;
}

function PostUrl(strfrm,objname,objname2) {
	var tmpobj=eval("document."+strfrm+"."+objname);
	var tmpobj2=eval("document."+strfrm+"."+objname2);
	for (var i=0;i<tmpobj.length;i++) {
		if (tmpobj2.value=='') {
			tmpobj2.value=tmpobj.options[i].value;
		} else {	
			tmpobj2.value+='@@@'+tmpobj.options[i].value;
		}
	}
}

function AddUrl(action,cname,objname) {
	var obj=document.getElementById(objname);
	if (!cname) {
		var thisurl='http://';
		Dialog.prompt('请输入链接',function(url){var obj=document.getElementById(objname);if (!action){if(url!=thisurl&&url!=null&&url!=''){obj.options[obj.selectedIndex]=new Option(url,url);};}else{if(url!=null&&url!=''){obj.options[obj.length]=new Option(url,url);};};this.close();},thisurl);
	} else {
		var thisurl=cname+(obj.length+1)+'|http://';
		Dialog.prompt('请输入'+cname+'和链接，中间用“|”隔开：',function(url){var obj=document.getElementById(objname);if (!action){if(url!=thisurl&&url!=null&&url!=''){obj.options[obj.selectedIndex]=new Option(url,url);};}else{if(url!=null&&url!=''){obj.options[obj.length]=new Option(url,url);};};this.close();},thisurl);
	}
}

function ModifyUrl(action,cname,objname) {
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	var thisurl=obj.value;
	if (!cname) {
		if (thisurl=='') {IsAlert('请先选择一个地址，再点修改按钮！');return false;}
		Dialog.prompt('请输入链接',function(url){var obj=document.getElementById(objname);if (!action){if(url!=thisurl&&url!=null&&url!=''){obj.options[obj.selectedIndex]=new Option(url,url);};}else{if(url!=null&&url!=''){obj.options[obj.length]=new Option(url,url);};};this.close();},thisurl);
	} else {
		if (thisurl=='') {IsAlert('请先选择一个'+cname+'，再点修改按钮！');return false;}
		Dialog.prompt('请输入'+cname+'和链接，中间用“|”隔开：',function(url){var obj=document.getElementById(objname);if (!action){if(url!=thisurl&&url!=null&&url!=''){obj.options[obj.selectedIndex]=new Option(url,url);};}else{if(url!=null&&url!=''){obj.options[obj.length]=new Option(url,url);};};this.close();},thisurl);
	}
}

function DelUrl(cname,objname) {
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	var thisurl=obj.value;
	if (!cname) {
		if (thisurl=='') {IsAlert('请先选择一个地址，再点删除按钮！');return false;}
	} else {
		if (thisurl=='') {IsAlert('请先选择一个'+cname+'，再点删除按钮！');return false;}
		if (obj.selectedIndex==0){IsAlert('不能删除第一个'+cname+'！');return false;}
	}
	obj.options[obj.selectedIndex]=null;
}

function UpUrl(cname,objname) {
	var obj=document.getElementById(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==0)) return false;
	if (!cname) {
		if (nIndex<0) {
			IsAlert("请选择一个要移动的地址！");
			return false;
		}
	} else {
		if (nIndex<0) {
			IsAlert("请选择一个要移动的"+cname+"！");
			return false;
		}
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex-1].value;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex-1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex-1;
}

function DownUrl(cname,objname) {
	var obj=document.getElementById(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==nLen-1)) return false;
	if (!cname) {
		if (nIndex<0) {
			IsAlert("请选择一个要移动的地址！");
			return false;
		}
	} else {
		if (nIndex<0) {
			IsAlert("请选择一个要移动的"+cname+"！");
			return false;
		}
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex+1].value;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex+1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex+1;
}

function regInput(obj, reg, inputStr) {
	var docSel = document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT") return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange = obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}

function getprice(Price_Original) {
	if(Price_Original==''|| isNaN(Price_Original)){Price_Original=0;}
	if(document.myform.ProductType[2].checked==true){document.myform.Price.value=Math.round(Price_Original*Math.abs(document.myform.Discount2.value/10)*100)/100;}
	else if(document.myform.ProductType[3].checked==true){document.myform.Price.value=Math.round(Price_Original*Math.abs(document.myform.Discount.value/10)*100)/100;}
	else {document.myform.Price.value=Price_Original;}
}

function ItemDialog(id,title,content,width,height) {
	var diag = new Dialog({
		id:id,
		title:title,
		url:content,
		width:width,
		height:height,
		modal:true
	});
	diag.onCancel=function(){
		$DW.close();
	};
	diag.show();
}

function ItemDialogLabel(id,title,content,width,height,elementId) {
	var diag = new Dialog({
		id:id,
		title:title,
		url:content,
		width:width,
		height:height,
		modal:true
	});
	diag.onOk = function(){
		$DW.ok();
		if($DW.$V("#Action")=="List"){
			if(!$DW.$V("#ClassID") || !$DW.$V("#MaxListNum") || isNaN($DW.$V("#MaxListNum")) || !$DW.$V("#TitleMaxLen") || isNaN($DW.$V("#TitleMaxLen")) || !$DW.$V("#StyleName")){
				return false;
			}
		}
		if($DW.$V("#Action")=="Image"){
			if(!$DW.$V("#ClassID") || !$DW.$V("#MaxPicNum") || isNaN($DW.$V("#MaxPicNum")) || !$DW.$V("#TitleMaxLen") || isNaN($DW.$V("#TitleMaxLen"))){
				return false;
			}
		}
		if($DW.$V("#Action")=="Flash"){
			if(!$DW.$V("#ClassID") || !$DW.$V("#TopNum") || isNaN($DW.$V("#TopNum")) || !$DW.$V("#TitleMaxLen") || isNaN($DW.$V("#TitleMaxLen"))){
				return false;
			}
		}
		if($DW.$V("#Action")=="Flashqq"){
			if(!$DW.$V("#ClassID") || !$DW.$V("#TopNum") || isNaN($DW.$V("#TopNum")) || !$DW.$V("#TitleMaxLen") || isNaN($DW.$V("#TitleMaxLen"))){
				return false;
			}
		}
		if($DW.$V("#Action")=="Class"){
			if(!$DW.$V("#ClassID") || !$DW.$V("#TopNum") || isNaN($DW.$V("#TopNum")) || !$DW.$V("#TitleMaxLen") || isNaN($DW.$V("#TitleMaxLen"))){
				return false;
			}
		}
		var values = $DW.$V("#SkinCode");
		if(values != "" && values != null){
			if (elementId=="MobanContent"){
				MobanContent.replaceSelection(values,MobanContent.getCursor());
				MobanContent.focus()
			}else if (elementId=="TemplateContent"){
				TemplateContent.replaceSelection(values,TemplateContent.getCursor());
				TemplateContent.focus()
			}else{
				codeMirrorEditor.replaceSelection(values,codeMirrorEditor.getCursor());
				codeMirrorEditor.focus()
			}
		}
		diag.close();
	};
	diag.onCancel=function(){
		$DW.close();
	};
	diag.show();
}

function AddLabel(id,title,content,width,height,elementId) {
	var diag = new Dialog({
		id:id,
		title:title,
		url:content,
		width:width,
		height:height,
		modal:true
	});
	diag.onOk = function(){
		$DW.ok();
		var values = $DW.$V("#SkinCode");
		if(values != "" && values != null){
			if (elementId=="LabelContent"){
				LabelContent.replaceSelection(values,LabelContent.getCursor());
				LabelContent.focus()
			}else if (elementId=="TemplateContent"){
				TemplateContent.replaceSelection(values,TemplateContent.getCursor());
				TemplateContent.focus()
			}else{
				codeMirrorEditor.replaceSelection(values,codeMirrorEditor.getCursor());
				codeMirrorEditor.focus()
			}
		}
		diag.close();
	};
	diag.onCancel=function(){
		$DW.close();
	};
	diag.show();
}

// 显示图片
function preview_image(file) {
	layer.alert('<p style="text-align: center;margin-bottom: 20px;"><a href="'+file+'" target="_blank">'+file+'</a></p><p style="text-align: center;margin-top: 20px;"><a href="'+file+'" target="_blank"><img style="max-width:100%;" src="'+file+'"></a></p>', {
		//scrollbar: false,
		id: 'FileView',
		title: '浏览文件！',
		area: ['70%', '70%'],
		btn: []
	});
}

// 多文件上传删除元素
function file_remove(e) {
	$(e).parents(".files_row").remove();
}

function tips(code, msg, time) {
	if (!time) {
		time = 3000;
	}
	var tip = '<i class="fa fa-info-circle"></i>';
	//var theme = 'teal';
	if (code >= 1) {
		tip = '<i class="fa fa-check-circle"></i>';
		//theme = 'lime';
	} else if (code == 0) {
		tip = '<i class="fa fa-times-circle"></i>';
		//theme = 'ruby';
	}
	layer.msg(tip+'&nbsp;&nbsp;'+msg);
}

function SelectFile(sChannelID,sModuleType,filetype,limit,objname,objname2,objname3,objname4,szutu,DownloadDir, UploadDir, InstallDir, Upath, Dir) {
	var url = pc_file + admin_file + 'Admin/Admin_UploadFile_Select.asp?channelid=' + sChannelID + '&filetype=' + filetype + '&limit=' + limit + '&rand=' + Math.random()
	var diag = new Dialog({
		id:'SelectFile',
		title:'<i class="fa fa-folder-open"></i> 附件管理',
		url:url,
		width:"70%",
		height:"60%",
		modal:true
	});
	diag.onOk = function(){
		var body = diag.innerFrame.contentWindow.document;
		$.ajax({type: "post",dataType:"json", url: url, data: $(body).find('#myform').serialize(),
			success: function(json) {
				if (json.code == 1) {
					//var temp = '<tr class="template-download files_row"><td style="text-align:center;"><span class="files_row_preview preview">{preview}</span></td><td class="files_show_info"><div class="row"><div class="col-md-6 hidden-mobile files_show_name"><input type="hidden" class="files_row_id" name="data[images][id][]" value="{id}"><input class="form-control files_row_name" type="text" name="data[images][file][]" value="{filepath}"></div><div class="col-md-6 col-xs-12 files_show_title"><input class="form-control files_row_title" type="text" name="data[images][title][]" value="{title}"></div></div></td><td style="text-align:center;"><label><button onclick="file_remove(this)" type="button" class="btn red file_delete btn-sm"><i class="fa fa-trash"></i></button></label></td></tr>';
					if (szutu == 1){
						var temp = '<li><div class="img"><a href="javascript:preview_image(\'{srcfilepath}\');""><img src="{srcfilepath}" width="100" height="80" border="0"></a></div><div class="pic_other"><div class="row-fluid"><div class="span9"><textarea name="'+objname3+'_desc">{title}</textarea></div><div class="span3"><button onclick="LeftArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-up cf"></i></button><button onclick="RightArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-down cf"></i></button><button onclick="DelArr(this)" type="button" class="btn red btn-sm"><i class="fa fa-trash cf"></i></button></div></div></div><input type="hidden" name="'+objname3+'" value="{filepath}" /></li>'
						var html = "";
						for(var i=0;i<json.data.result.length;i++){
							var tpl = temp;
							var v = json.data.result[i];
							tpl = tpl.replace(/\{preview\}/g, v.preview);
							tpl = tpl.replace(/\{id\}/g, v.id);
							if (DownloadDir != null){
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file.replace(DownloadDir,'{$download_dir}'));
									$S(objname).value=v.file.replace(DownloadDir,'{$download_dir}');
									$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(DownloadDir,'{$download_dir}'),v.file.replace(DownloadDir,'{$download_dir}'));
								}
							}else if (UploadDir != null){
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file.replace(UploadDir,'{$upload_dir}'));
									$S(objname).val(v.file.replace(UploadDir,'{$upload_dir}'));
									$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(UploadDir,'{$upload_dir}'),v.file.replace(UploadDir,'{$upload_dir}'));
								}
							}else if (InstallDir != null){
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file.replace(InstallDir,'{$InstallDir}'));
									$S(objname).val(v.file.replace(InstallDir,'{$InstallDir}'));
									$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(InstallDir,'{$InstallDir}'),v.file.replace(InstallDir,'{$InstallDir}'));
								}
							}else{
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file);
									$S(objname).val(v.file);
									$S(objname2).options[$S(objname2).length]=new Option(v.file,v.file);
								}
							}
							tpl = tpl.replace(/\{srcfilepath\}/g, v.url);
							tpl = tpl.replace(/\{title\}/g, v.name);
							html+= tpl;
						}
						if (objname4 != null) {
							$($S(objname4)).prepend(html);
						}
					}else{
						if (sModuleType == 3 && filetype == 2){
							for(var i=0;i<json.data.result.length;i++){
								var v = json.data.result[i];
								if (DownloadDir != null){
									if (null != v.file) {
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(DownloadDir,'{$download_dir}'),v.file.replace(DownloadDir,'{$download_dir}'));
										if (objname3 != null){
											var a = '下载地址'+($S(objname3).length+1)+'|'+v.file.replace(DownloadDir,'{$download_dir}');
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}else if (UploadDir != null){
									if (null != v.file) {
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(UploadDir,'{$upload_dir}'),v.file.replace(UploadDir,'{$upload_dir}'));
										if (objname3 != null){
											var a = '下载地址'+($S(objname3).length+1)+'|'+v.file.replace(UploadDir,'{$upload_dir}');
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}else if (InstallDir != null){
									if (null != v.file) {
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(InstallDir,'{$InstallDir}'),v.file.replace(InstallDir,'{$InstallDir}'));
										if (objname3 != null){
											var a = '下载地址'+($S(objname3).length+1)+'|'+v.file.replace(InstallDir,'{$InstallDir}');
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}else{
									if (null != v.file) {
										$S(objname2).options[$S(objname2).length]=new Option(v.file,v.file);
										if (objname3 != null){
											var a = '下载地址'+($S(objname3).length+1)+'|'+v.file;
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}
							}
						}else if (sModuleType == 2 && filetype == 1){
							for(var i=0;i<json.data.result.length;i++){
								var v = json.data.result[i];
								if (DownloadDir != null){
									if (null != v.file) {
										$S(objname).value=v.file.replace(DownloadDir,'{$download_dir}');
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(DownloadDir,'{$download_dir}'),v.file.replace(DownloadDir,'{$download_dir}'));
										if (objname3 != null){
											var a = '图片名称'+($S(objname3).length+1)+'|'+v.file.replace(DownloadDir,'{$download_dir}');
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}else if (UploadDir != null){
									if (null != v.file) {
										$S(objname).val(v.file.replace(UploadDir,'{$upload_dir}'));
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(UploadDir,'{$upload_dir}'),v.file.replace(UploadDir,'{$upload_dir}'));
										if (objname3 != null){
											var a = '图片名称'+($S(objname3).length+1)+'|'+v.file.replace(UploadDir,'{$upload_dir}');
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}else if (InstallDir != null){
									if (null != v.file) {
										$S(objname).val(v.file.replace(InstallDir,'{$InstallDir}'));
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(InstallDir,'{$InstallDir}'),v.file.replace(InstallDir,'{$InstallDir}'));
										if (objname3 != null){
											var a = '图片名称'+($S(objname3).length+1)+'|'+v.file.replace(InstallDir,'{$InstallDir}');
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}else{
									if (null != v.file) {
										$S(objname).val(v.file);
										$S(objname2).options[$S(objname2).length]=new Option(v.file,v.file);
										if (objname3 != null){
											var a = '图片名称'+($S(objname3).length+1)+'|'+v.file;
											$S(objname3).options[$S(objname3).length] = new Option(a,a);
										}
										if (objname4 != null){
											$S(objname4).value = v.size.replace(' KB','');
										}
									}
								}
							}
						}else{
							for(var i=0;i<json.data.result.length;i++){
								var v = json.data.result[i];
								if (DownloadDir != null){
									if (null != v.file) {
										$S(objname).value=v.file.replace(DownloadDir,'{$download_dir}');
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(DownloadDir,'{$download_dir}'),v.file.replace(DownloadDir,'{$download_dir}'));
									}
								}else if (UploadDir != null){
									if (null != v.file) {
										$S(objname).val(v.file.replace(UploadDir,'{$upload_dir}'));
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(UploadDir,'{$upload_dir}'),v.file.replace(UploadDir,'{$upload_dir}'));
									}
								}else if (InstallDir != null){
									if (null != v.file) {
										$S(objname).val(v.file.replace(InstallDir,'{$InstallDir}'));
										$S(objname2).options[$S(objname2).length]=new Option(v.file.replace(InstallDir,'{$InstallDir}'),v.file.replace(InstallDir,'{$InstallDir}'));
									}
								}else{
									if (null != v.file) {
										$S(objname).val(v.file);
										$S(objname2).options[$S(objname2).length]=new Option(v.file,v.file);
									}
								}
							}
						}
					}
					//$('#fileupload_images_files').append(html);
					//<table role="presentation" class="table table-striped table-fc-upload clearfix"><tbody id="fileupload_images_files" class="files"></tbody></table>
					//tips(1, json.msg);
					layer.msg(json.msg,{icon: 1, time: 1000});
					diag.close();
				} else {
					//tips(0, json.msg);
					Dialog.alert(json.msg);
				}
			}
		});
	};
	diag.onCancel=function(){
		diag.close();
	};
	diag.show();
	/*layer.open({
		type: 2,
		title: '<i class="fa fa-folder-open"></i> 附件管理',
		fix:true,
		scrollbar: false,
		shadeClose: true,
		shade: 0,
		area: ["70%", "60%"],
		btn: ["确定"],
		yes: function(index, layero){
			var body = layer.getChildFrame('body', index);
			// 延迟加载
			var loading = layer.load(2, {
				time: 10000000
			});
			$.ajax({type: "post",dataType:"json", url: url, data: $(body).find('#myform').serialize(),
				success: function(json) {
					layer.close(loading);
					if (json.code == 1) {
						layer.close(index);
						//var temp = '<tr class="template-download files_row"><td style="text-align:center;"><span class="files_row_preview preview">{preview}</span></td><td class="files_show_info"><div class="row"><div class="col-md-6 hidden-mobile files_show_name"><input type="hidden" class="files_row_id" name="data[images][id][]" value="{id}"><input class="form-control files_row_name" type="text" name="data[images][file][]" value="{filepath}"></div><div class="col-md-6 col-xs-12 files_show_title"><input class="form-control files_row_title" type="text" name="data[images][title][]" value="{title}"></div></div></td><td style="text-align:center;"><label><button onclick="file_remove(this)" type="button" class="btn red file_delete btn-sm"><i class="fa fa-trash"></i></button></label></td></tr>';
						var temp = '<li><div class="img"><img src="{srcfilepath}" width="100" height="80" border="0"></div><div class="pic_other"><div class="row-fluid"><div class="span9"><textarea name="'+objname3+'_desc">{title}</textarea></div><div class="span3"><button onclick="LeftArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-up cf"></i></button><button onclick="RightArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-down cf"></i></button><button onclick="DelArr(this)" type="button" class="btn red btn-sm"><i class="fa fa-trash cf"></i></button></div></div></div><input type="hidden" name="'+objname3+'" value="{filepath}" /></li>'
						var html = "";
						for(var i=0;i<json.data.result.length;i++){
							var tpl = temp;
							var v = json.data.result[i];
							tpl = tpl.replace(/\{preview\}/g, v.preview);
							tpl = tpl.replace(/\{id\}/g, v.id);
							if (DownloadDir != null){
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file.replace(DownloadDir,'{$download_dir}'));
									$('#'+objname).val(v.file.replace(DownloadDir,'{$download_dir}'));
									document.getElementById(objname2).options[document.getElementById(objname2).length]=new Option(v.file.replace(DownloadDir,'{$download_dir}'),v.file.replace(DownloadDir,'{$download_dir}'));
								}
							}else if (UploadDir != null){
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file.replace(UploadDir,'{$upload_dir}'));
									$('#'+objname).val(v.file.replace(UploadDir,'{$upload_dir}'));
									document.getElementById(objname2).options[document.getElementById(objname2).length]=new Option(v.file.replace(UploadDir,'{$upload_dir}'),v.file.replace(UploadDir,'{$upload_dir}'));
								}
							}else if (InstallDir != null){
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file.replace(InstallDir,'{$InstallDir}'));
									$('#'+objname).val(v.file.replace(InstallDir,'{$InstallDir}'));
									document.getElementById(objname2).options[document.getElementById(objname2).length]=new Option(v.file.replace(InstallDir,'{$InstallDir}'),v.file.replace(InstallDir,'{$InstallDir}'));
								}
							}else{
								if (null != v.file) {
									tpl = tpl.replace(/\{filepath\}/g, v.file);
									$('#'+objname).val(v.file);
									document.getElementById(objname2).options[document.getElementById(objname2).length]=new Option(v.file,v.file);
								}
							}
							tpl = tpl.replace(/\{srcfilepath\}/g, v.url);
							tpl = tpl.replace(/\{title\}/g, v.name);
							html+= tpl;
						}
						$('#'+objname4).prepend(html);
						//$('#fileupload_images_files').append(html);
						//tips(1, json.msg);
						layer.msg(json.msg,{icon: 1, time: 1000});
					} else {
						//tips(0, json.msg);
						layer.msg(json.msg,{icon: 2, time: 1000});
					}
					return false;
				}
			});
			return false;
		},
		success: function(layero, index){
			// 主要用于权限验证
			var body = layer.getChildFrame('body', index);
			var json = $(body).html();
			if (json.indexOf('"code":0') > 0 && json.length < 150){
				var obj = JSON.parse(json);
				layer.close(index);
				tips(0, obj.msg);
			}
			if (json.indexOf('"code":1') > 0 && json.length < 150){
				var obj = JSON.parse(json);
				layer.close(index);
				tips(1, obj.msg);
			}
		},
		content: url
	});*/
}

function AddImage(objname,objname2,oFieldVerify) {
	var diag = new Dialog({
		id:'AddImage',
		title:'远程图片',
		html:'<dl style="margin: 0;padding: 0;font-size: 12px;color: #444;"><dt><b>图片地址：</b><textarea id="picurl" style="width: 75%;height: 120px;border-right: 1px solid #E8E8E8;border-bottom: 1px solid #E8E8E8;padding: 5px 0 4px 2px;font-family: verdana;overflow: hidden;vertical-align: top;"></textarea><div style="color: #999;line-height: 30px;padding: 0 0 0 65px;">一行一个图片地址，示例：图片地址|图片名称</div></dt></dl>',
		width:580,
		height:180,
		modal:true,
		onShow: function() {
			picurl = this.dom.$body.find("textarea")[0], picurl.select(), picurl.focus()
		},
	});
	diag.onOk = function(){
		var t0 = picurl.value;
		if(t0==""){
			Dialog.alert("\u56fe\u7247\u5730\u5740\u4e0d\u80fd\u4e3a\u7a7a\uff01", function() {
				picurl.focus();
			});
			return false
		}else{
			var arr, picarr;
			if (!isEmpty(oFieldVerify)){
				oFieldVerify = ' lay-verify="required"';
			}
			arr=t0.split("\n");
			for(i=0;i<arr.length;i++){
				picarr=arr[i].split("|");
				if (isEmpty(picarr[1])){
					picarr[1]="";
				}
				var ImageHtml='<li>'
				ImageHtml+='    <div class="img">'
				ImageHtml+='        <img src="'+picarr[0]+'" width="100" height="80" border="0">'
				ImageHtml+='    </div>'
				ImageHtml+='    <div class="pic_other">'
				ImageHtml+='        <div class="row-fluid">'
				ImageHtml+='            <div class="span9"><textarea name="'+objname+'_desc"'+oFieldVerify+'>'+picarr[1]+'</textarea></div>'
				ImageHtml+='            <div class="span3"><button onclick="LeftArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-up cf"></i></button><button onclick="RightArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-down cf"></i></button><button onclick="DelArr(this)" type="button" class="btn red btn-sm"><i class="fa fa-trash cf"></i></button></div>'
				ImageHtml+='       </div>'
				ImageHtml+='   </div>'
				ImageHtml+='   <input type="hidden" name="'+objname+'" value="'+picarr[0]+'" />'
				ImageHtml+='</li>'
				$($S(objname2)).prepend(ImageHtml)
			}
		}
		diag.close();
	};
	diag.onCancel=function(){
		diag.close();
	};
	diag.show();
}

//左移
function LeftArr(objname) {
	var $Imageli=$(objname).parent().parent().parent().parent();
	var $ImagePrevli=$Imageli.prev("li");
	if($ImagePrevli.length>0){$ImagePrevli.insertAfter($Imageli);}
}

//右移
function RightArr(objname) {
	var $Imageli=$(objname).parent().parent().parent().parent();
	var $ImageNextli=$Imageli.next("li");
	if($ImageNextli.length>0){$ImageNextli.insertBefore($Imageli);}
}

//删除
function DelArr(objname) {
	var thispic=$(objname).parent().parent().parent().parent();
	Dialog.confirm('\u786e\u5b9a\u8981\u6e05\u7a7a\uff1f', function(){thispic.remove();});
}

//清空
function ClearImage(objname) {
	var thispic=$("#"+objname+" li");
	Dialog.confirm('\u786e\u5b9a\u8981\u6e05\u7a7a\uff1f', function(){thispic.remove();});
}

function UploadFile(sChannelID,sModuleType,filetype,cid,classid,limit,compress,szutu,objname,objname2,objname3,objname4,oFieldVerify,DownloadDir, UploadDir, InstallDir, Upath, Dir) {
	var diag = new Dialog({
		id:'UploadFile',
		title:'<i class="fa fa-folder-open"></i> 文件上传',
		url:pc_file + admin_file + "Include/Uploader.asp?channelid=" + sChannelID + "&filetype=" + filetype + "&cid=" + cid + "&classid=" + classid + "&limit=" + limit + "&compress=" + compress + "",
		width:650,
		height:400,
		modal:true
	});
	diag.onOk = function(){
		if (szutu == 1){
			var b, c, d, e, a = $($DW.$("#filelist")).html();
			if (!isEmpty(oFieldVerify)){
				oFieldVerify = ' lay-verify="required"';
			}
			if (DownloadDir != null){
				if (null != a && '' != a) {
					b = a.substring(1);
					c = b.split("|");
					for (i = 0; i < c.length; i++) {
						d = c[i].split('@@@')
						if (objname3 != null){
							$S(objname3).value = d[0].replace(DownloadDir,'{$download_dir}');
						}
						if (objname4 != null){
							AddUploadFile(objname4,d[0].replace(DownloadDir,'{$download_dir}'));
						}
					}
					for (b = a.substring(1), c = b.split("|"), e = "", i = 0; i < c.length; i++) d = c[i].split('@@@'), e += "<li>", e += '    <div class="img">', e += '        <img src="' + d[0] + '" width="100" height="80" border="0">', e += "    </div>", e += '    <div class="pic_other">', e += '        <div class="row-fluid">', e += '            <div class="span9"><textarea name="'+objname+'_desc"'+oFieldVerify+'>' + d[1] + '</textarea></div>', e += '            <div class="span3"><button onclick="LeftArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-up cf"></i></button><button onclick="RightArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-down cf"></i></button><button onclick="DelArr(this)" type="button" class="btn red btn-sm"><i class="fa fa-trash cf"></i></button></div>', e += "       </div>", e += "   </div>", e += '   <input type="hidden" name="'+objname+'" value="' + d[0].replace(DownloadDir,'{$download_dir}') + '" />', e += "</li>";
					$($S(objname2)).prepend(e)
				}
			}else if (UploadDir != null){
				if (null != a && '' != a) {
					b = a.substring(1);
					c = b.split("|");
					for (i = 0; i < c.length; i++) {
						d = c[i].split('@@@')
						if (objname3 != null){
							$S(objname3).value = d[0].replace(UploadDir,'{$upload_dir}');
						}
						if (objname4 != null){
							AddUploadFile(objname4,d[0].replace(UploadDir,'{$upload_dir}'));
						}
					}
					for (b = a.substring(1), c = b.split("|"), e = "", i = 0; i < c.length; i++) d = c[i].split('@@@'), e += "<li>", e += '    <div class="img">', e += '        <img src="' + d[0] + '" width="100" height="80" border="0">', e += "    </div>", e += '    <div class="pic_other">', e += '        <div class="row-fluid">', e += '            <div class="span9"><textarea name="'+objname+'_desc"'+oFieldVerify+'>' + d[1] + '</textarea></div>', e += '            <div class="span3"><button onclick="LeftArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-up cf"></i></button><button onclick="RightArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-down cf"></i></button><button onclick="DelArr(this)" type="button" class="btn red btn-sm"><i class="fa fa-trash cf"></i></button></div>', e += "       </div>", e += "   </div>", e += '   <input type="hidden" name="'+objname+'" value="' + d[0].replace(UploadDir,'{$upload_dir}') + '" />', e += "</li>";
					$($S(objname2)).prepend(e)
				}
			}else if (InstallDir != null){
				if (null != a && '' != a) {
					b = a.substring(1);
					c = b.split("|");
					for (i = 0; i < c.length; i++) {
						d = c[i].split('@@@')
						if (objname3 != null){
							$S(objname3).value = d[0].replace(InstallDir,'{$InstallDir}');
						}
						if (objname4 != null){
							AddUploadFile(objname4,d[0].replace(InstallDir,'{$InstallDir}'));
						}
					}
					for (b = a.substring(1), c = b.split("|"), e = "", i = 0; i < c.length; i++) d = c[i].split('@@@'), e += "<li>", e += '    <div class="img">', e += '        <img src="' + d[0] + '" width="100" height="80" border="0">', e += "    </div>", e += '    <div class="pic_other">', e += '        <div class="row-fluid">', e += '            <div class="span9"><textarea name="'+objname+'_desc"'+oFieldVerify+'>' + d[1] + '</textarea></div>', e += '            <div class="span3"><button onclick="LeftArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-up cf"></i></button><button onclick="RightArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-down cf"></i></button><button onclick="DelArr(this)" type="button" class="btn red btn-sm"><i class="fa fa-trash cf"></i></button></div>', e += "       </div>", e += "   </div>", e += '   <input type="hidden" name="'+objname+'" value="' + d[0].replace(InstallDir,'{$InstallDir}') + '" />', e += "</li>";
					$($S(objname2)).prepend(e)
				}
			}else{
				if (null != a && '' != a) {
					b = a.substring(1);
					c = b.split("|");
					for (i = 0; i < c.length; i++) {
						d = c[i].split('@@@')
						if (objname3 != null){
							$S(objname3).value = d[0];
						}
						if (objname4 != null){
							AddUploadFile(objname4,d[0]);
						}
					}
					for (b = a.substring(1), c = b.split("|"), e = "", i = 0; i < c.length; i++) d = c[i].split('@@@'), e += "<li>", e += '    <div class="img">', e += '        <img src="' + d[0] + '" width="100" height="80" border="0">', e += "    </div>", e += '    <div class="pic_other">', e += '        <div class="row-fluid">', e += '            <div class="span9"><textarea name="'+objname+'_desc"'+oFieldVerify+'>' + d[1] + '</textarea></div>', e += '            <div class="span3"><button onclick="LeftArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-up cf"></i></button><button onclick="RightArr(this)" type="button" class="btn green btn-sm"><i class="fa fa-arrow-down cf"></i></button><button onclick="DelArr(this)" type="button" class="btn red btn-sm"><i class="fa fa-trash cf"></i></button></div>', e += "       </div>", e += "   </div>", e += '   <input type="hidden" name="'+objname+'" value="' + d[0] + '"'+oFieldVerify+' />', e += "</li>";
					$($S(objname2)).prepend(e)
				}
			}
		}else{
			if (sModuleType == 3 && filetype == 2){
				var b, c, d, e, a = $($DW.$("#filelist")).html();
				if (DownloadDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							e = '下载地址'+($S(objname2).length+1)+'|'+d[0].replace(DownloadDir,'{$download_dir}');
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0].replace(DownloadDir,'{$download_dir}'));
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}else if (UploadDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							e = '下载地址'+($S(objname2).length+1)+'|'+d[0].replace(UploadDir,'{$upload_dir}');
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0].replace(UploadDir,'{$upload_dir}'));
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}else if (InstallDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							e = '下载地址'+($S(objname2).length+1)+'|'+d[0].replace(InstallDir,'{$InstallDir}');
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0].replace(InstallDir,'{$InstallDir}'));
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}else{
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							e = '下载地址'+($S(objname2).length+1)+'|'+d[0];
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0]);
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}
			}else if (sModuleType == 2 && filetype == 1){
				var b, c, d, e, a = $($DW.$("#filelist")).html();
				if (DownloadDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							if (objname != null){
								$S(objname).value = d[0].replace(DownloadDir,'{$download_dir}');
							}
							e = '图片名称'+($S(objname2).length+1)+'|'+d[0].replace(DownloadDir,'{$download_dir}');
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0].replace(DownloadDir,'{$download_dir}'));
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}else if (UploadDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							if (objname != null){
								$S(objname).value = d[0].replace(UploadDir,'{$upload_dir}');
							}
							e = '图片名称'+($S(objname2).length+1)+'|'+d[0].replace(UploadDir,'{$upload_dir}');
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0].replace(UploadDir,'{$upload_dir}'));
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}else if (InstallDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							if (objname != null){
								$S(objname).value = d[0].replace(InstallDir,'{$InstallDir}');
							}
							e = '图片名称'+($S(objname2).length+1)+'|'+d[0].replace(InstallDir,'{$InstallDir}');
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0].replace(InstallDir,'{$InstallDir}'));
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}else{
					if (null != a) {
						b = a.substring(1);
						c = b.split("|");
						for (i = 0; i < c.length; i++) {
							d = c[i].split('@@@')
							if (objname != null){
								$S(objname).value = d[0];
							}
							e = '图片名称'+($S(objname2).length+1)+'|'+d[0];
							$S(objname2).options[$S(objname2).length] = new Option(e,e);
							if (objname3 != null){
								AddUploadFile(objname3,d[0]);
							}
							if (objname4 != null){
								$S(objname4).value = d[2];
							}
						}
					}
				}
			}else{
				var b, c, a = $($DW.$("#filelist")).html();
				if (DownloadDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split('@@@');
						$S(objname).value = c[0].replace(DownloadDir,'{$download_dir}');
						if (objname2 != null){
							AddUploadFile(objname2,c[0].replace(DownloadDir,'{$download_dir}'));
						}
					}
				}else if (UploadDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split('@@@');
						$S(objname).value = c[0].replace(UploadDir,'{$upload_dir}');
						if (objname2 != null){
							AddUploadFile(objname2,c[0].replace(UploadDir,'{$upload_dir}'));
						}
					}
				}else if (InstallDir != null){
					if (null != a) {
						b = a.substring(1);
						c = b.split('@@@');
						$S(objname).value = c[0].replace(InstallDir,'{$InstallDir}');
						if (objname2 != null){
							AddUploadFile(objname2,c[0].replace(InstallDir,'{$InstallDir}'));
						}
					}
				}else{
					if (null != a) {
						b = a.substring(1);
						c = b.split('@@@');
						$S(objname).value = c[0];
						if (objname2 != null){
							AddUploadFile(objname2,c[0]);
						}
					}
				}
			}
		}
		diag.close();
	};
	diag.onCancel=function(){
		diag.close();
	};
	diag.show();
}

function AddUploadFile(objname,files) {
	if (files == "") {
		return;
	}
	if(objname!='') {
		var obj = document.getElementById(objname);
		obj.options[obj.length]=new Option(files,files);
	}
}

function SelectCss(objname) {
	ItemDialog('CssFile','选择风格',pc_file + admin_file + 'Admin/Admin_CssFileSelect.asp?objname=' + objname,800,450)
}

function SelectMoban(sChannelID,objname) {
	ItemDialog('MobanFile','选择模板',pc_file + admin_file + 'Admin/Admin_MobanFileSelect.asp?ChannelID=' + sChannelID + '&objname=' + objname,800,450)
}

function SelectColor(tcstr) {
	var diag = new Dialog({
		id:'Color',
		title:'颜色选择',
		url:pc_file + admin_file + 'Include/SelColor.asp?name=' + tcstr + '&color=' + document.getElementById(tcstr).value,
		width:400,
		height:240,
		modal:true
	});
	diag.onOk = function() {
		var dR = $DW.$V("#D_SelColor");
		if(!dR){
			Dialog.alert("颜色值不能为空！", function() {
				$DW.$('#D_SelColor').focus();
			});
			return false;
		}
		if (!mH(dR)) {
			Dialog.alert("无效的颜色值！", function() {
				$DW.$('#D_SelColor').focus();
			});
			return false;
		}
		if (dR.length == 7) {
			dR = dR.substr(1, dR.length);
		}
		$S(tcstr).style.backgroundColor = $DW.$V("#D_SelColor");
		$S(tcstr).style.color = getFontColor(dR);
		$S(tcstr).value = dR;
		diag.close();
	};
	diag.onCancel=function() {
		$DW.close();
	};
	diag.show();
}

function ClearColor(tcstr) {
	eval("window.document.all."+tcstr+".value='';window.document.all."+tcstr+".style.backgroundColor='';window.document.all."+tcstr+".style.color='';");
}

function mH(color) {
	var tf = color;
	if (tf == "") return true;
	if (tf.length != 7) return false;
	return (tf.search(/\#[a-fA-F0-9]{6}/) != -1)
}

function getFontColor(x) {
	var rgb = 0xffffff - parseInt('0x' + x);
	var r = rgb % 0x100,
	g = parseInt(rgb / 0x100) % 0x100,
	b = parseInt(rgb / 0x10000) % 0x100;
	if (r > 128 || g > 128 || b > 128) return '#FFFFFF';
	else return '#000000'
}

function SelectTime(id,format,mintime,maxtime)
{
	if (!mintime=='') {
		$.calendar({ id: '#'+id, format: format, minDate:'#'+mintime });
	}else if (!maxtime==''){
		$.calendar({ id: '#'+id, format: format, maxDate:'#'+maxtime });
	}else{
		$.calendar({ id: '#'+id, format: format });
	}
}

function SelectPresent(sChannelID,ChannelDir,objname) {
	ItemDialog(ChannelDir,'选择商品',pc_file + admin_file + ChannelDir + '/Admin_Select' + ChannelDir + '.asp?ChannelID=' + sChannelID + '&ProductType=4&objname=' + objname,850,500)
}

function AddDependentProduct(sChannelID,ChannelDir,objname) {
	ItemDialog(ChannelDir,'选择商品',pc_file + admin_file + ChannelDir + '/Admin_Select' + ChannelDir + '.asp?ChannelID=' + sChannelID + '&objname=' + objname,850,500)
}

function DelDependentProduct(sChannelID,ChannelDir,objname) {
	if(document.getElementById(objname).length==0) return false;
	var thisurl=document.getElementById(objname).value;
	if (thisurl=='') {IsAlert('请先选择一个换购礼品，再点删除按钮！');return false;}
	document.getElementById(objname).options[document.getElementById(objname).selectedIndex]=null;
}

function add_mk() {
	$('#cpboxadd').show(300)
}

function edit_mk(obj,id) {
	var Mk='';
	ItemDialog('Mk','修改快捷',pc_file + admin_file + 'Admin/Admin_Index_Mk.asp?action=edit&id='+id,700,500)
}

function add_mkb(obj,id) {
	var Mk='';
	ItemDialog('Mk','新增快捷',pc_file + admin_file + 'Admin/Admin_Index_Mk.asp?action=add',700,500)
}

function sel_mk() {
	var Mk='';
	ItemDialog('Mk','选择快捷',pc_file + admin_file + 'Admin/Admin_Index_Mk.asp',800,500)
}

function delbox(obj,id) {
	Dialog.confirm('确定要删除快捷菜单操作吗？', function(){del_mk(obj,id);}, function(){});
}

function del_mk(obj,id) {
	//$(obj).parent().parent().hide(500)
	$(obj).parent().parent().attr("title","del")
	$.get(pc_file + admin_file + 'Admin/Admin_Index_Mk.asp',{id:id,action:"del_mk",anticache:Math.floor(Math.random()*1000)},function(d){});
	$(obj).parent().parent().remove();
}

function SelectObjItem1(Obj,OpStr,ButtonSymbol,MainUrl) {
	//if (OpStr!='') {
		//window.parent.parent.frames['bottom'].location.href= pc_file + admin_file + 'Admin_Bottom.asp?OpStr='+escape(OpStr)+'&ButtonSymbol='+escape(ButtonSymbol);
	//}
	if(MainUrl!='') {
		window.parent.parent.frames['main'].location.href=MainUrl;
	}
}

function rUseLinkUrl() {
	if (document.myform.UseLinkUrl.checked==true){
		document.myform.LinkUrl.disabled=false;
		ChannelContent.style.display='none';
		ChannelMoban.style.display='none';
		ChannelMoban2.style.display='none';
		//ChannelMoban3.style.display='none';
		ChannelPage.style.display='none';
		ChannelPage2.style.display='none';
		ChannelPage3.style.display='none';
		MobanTag.style.display='none';
	} else {
		document.myform.LinkUrl.disabled=true;
		ChannelContent.style.display='';
		ChannelMoban.style.display='';
		ChannelMoban2.style.display='';
		//ChannelMoban3.style.display='';
		ChannelPage.style.display='';
		ChannelPage2.style.display='';
		ChannelPage3.style.display='';
		MobanTag.style.display='';
	}
}

function rNotNull(){
	if (document.myform.NotNull.checked==true) {
		Verification.style.display='';
		Verification2.style.display='';
		Verification3.style.display='';
	} else {
		Verification.style.display='none';
		Verification2.style.display='none';
		Verification3.style.display='none';
	}
}

function check_title(name, ChannelID, ChannelDir, ID, url, t) {
	var val = $("#" + name).val();
	$.get(pc_file + admin_file + ChannelDir + url + "?Action=CheckTitle&Title=" + val + "&ChannelID=" + ChannelID + "&ID=" + ID + "&rand=" + Math.random(), function(data) {
		if (data) {
			if (t == "1") {
				Dialog.alert(data)
			} else {
				$("#title_tips").html(data)
			}
		}
	})
}
function get_keywords(name, ChannelDir, url, to) {
	var title = $("#" + name).val();
	if ($("#" + to).val()) {
		return false
	}
	$.get(pc_file + admin_file + ChannelDir + url + "?Action=GetKeyWords&Title=" + title + "&rand=" + Math.random(), function(data) {
		$("#" + to).val(data);
		$("#" + to).tagsinput('add', data)
	})
}
function to_pinyin(name, from, url) {
	var val = $("#" + from).val();
	if ($("#" + name).val()) {
		return false
	}
	$.get(pc_file + admin_file + "Admin/" + url + "?Action=ToPinyin&ClassName=" + val + "&rand=" + Math.random(), function(data) {
		$("#" + name).val(data);
	})
}

function IsAlert(msg) {
	Dialog.alert(msg);
}

function IsAlertFocus(msg,content) {
	Dialog.alert(msg,function(){if(content=='MobanContent'){MobanContent.focus();}else if(content=='TemplateContent'){TemplateContent.focus();}else{document.getElementById(content).focus();}});
}

function IsAlertFocusSelect(msg,content) {
	Dialog.alert(msg,function(){document.getElementById(content).focus();document.getElementById(content).select();});
}

function IsSuccess(msg,url) {
	Dialog.alert(msg,function(){window.location = url;});
}

function IsConfirm(msg,okurl,cancelurl) {
	Dialog.confirm(msg, function(){window.location = okurl;}, function(){if(!cancelurl==''){window.location = cancelurl;}else{}});
}

function IsLogoutConfirm(msg,okurl) {
	Dialog.confirm(msg, function(){window.top.location = okurl;});
}

function SubmitConfirm(alertmsg,msg,ID,url) {
	if (ID!="") {
		var arr = document.getElementsByName(ID);
		var flag = false;
		for (var i=0;i<arr.length;i++) {
			if (arr[i].checked) {
				flag = true;
				break;
			}
		}
		if (!flag) {
			Dialog.alert(alertmsg);
			return false;
		}
	}
	Dialog.confirm(msg,function() {
		document.myform.Action.value=url;
		document.myform.submit();
	});
}

function ResetConfirm(msg) {
	Dialog.confirm(msg,function() {
		//if (doReset==1){
			//UE.getEditor('Content').setContent("");
		//}
		//if (doReset==2){
			//MobanContent.setValue("");
		//}
		//if (doReset==3){
			//TemplateContent.setValue("");
		//}
		document.myform.reset();
	});
}

function OpenClose() {
	if($("#openclose").data('clicknum')==1) {
		$(".treelistframe").show();
		$("#openclose").children('.fa').addClass("fa-chevron-left").removeClass("fa-chevron-right");
		$("#openclose").data('clicknum', 0);
	} else {
		$(".treelistframe").hide();
		$("#openclose").children('.fa').addClass("fa-chevron-right").removeClass("fa-chevron-left");
		$("#openclose").data('clicknum', 1);
	}
	return false;
}